<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Document</title>
		<!-- 引入样式 -->
		<link rel="stylesheet" href="../../plugins/element-ui/index.css" />
		<link rel="stylesheet" href="../../styles/common.css" />
		<link rel="stylesheet" href="../../styles/page.css" />
		
		
	</head>
	<body>
		<div class="addBrand-container" id="member-add-app">
			<div style="background-color: #ff7744; width: 100%; height: 40px; padding: 10px; font-family: Arial, sans-serif; font-size: 16px; line-height: 1.5; color: whitesmoke; border: 4px solid whitesmoke; border-radius: 15%;">
			  如有任何疑问或需要进一步协助，请拨打我们的支持热线：<span style="font-weight: bold;">101-1045783</span>，或发送邮件至<span style="font-weight: bold;">janyao520@163.com</span>。我们的团队将竭诚为您服务！
			</div>
			<div class="container">
				<el-form  :model="form" label-width="180px"
					>
					<el-form-item label="航班号:" prop="cfno">
						<el-input v-model="form.cfno" maxlength="20" disabled />
					</el-form-item>
					<el-form-item label="起始站:" prop="star" >
						<el-input v-model="form.star" maxlength="20" disabled />
					</el-form-item>

					<el-form-item label="终点站:" prop="ends" >
						<el-input v-model="form.ends" maxlength="20" disabled/>
					</el-form-item>
					
					<el-form-item label="航班时间">
						<template>
							<div class="block">
					
								<el-date-picker v-model="form.dateTime" type="datetimerange" range-separator="-"
									start-placeholder="航班起飞时间" end-placeholder="航班降落时间">
								</el-date-picker>
							</div>
							
						
						</template>
					</el-form-item>
					<el-form-item label="变更原因:" prop="reason" >
					<el-input
					  type="textarea"
					  :autosize="{ minRows: 2, maxRows: 4}"
					  placeholder="请输入变更原因 "
					  v-model="form.textarea" 
					  style="width: 400px;">
					</el-input>
					
					</el-form-item>
					
					
					<div class="subBox address">
						<el-form-item>
							<el-button @click="goBack()">
								取消
							</el-button>
							<el-button type="primary" @click="submitForm('form', false)">
								提交
							</el-button>
							
						</el-form-item>
					</div>
				</el-form>
			</div>
		</div>
		<!-- 开发环境版本，包含了有帮助的命令行警告 -->
		<script src="../../plugins/vue/vue.js"></script>
		<!-- 引入组件库 -->
		<script src="../../plugins/element-ui/index.js"></script>
		<!-- 引入axios -->
		<script src="../../plugins/axios/axios.min.js"></script>
		<script src="../../js/request.js"></script>
		<script src="../../api/member.js"></script>
		<script src="../../js/validate.js"></script>
		<script src="../../js/index.js"></script>
		<script>
			new Vue({
				el: '#member-add-app',
				data() {
					return {
						textarea: '',
						form: {
							cfno:'',
							star:'',
							ends:'',
							dateTime:[],
							textarea: ''
						}
					}
				},
				
				created() {
					// data = requestUrlParam('data')
					var info = sessionStorage.getItem("apply")
					this.form = JSON.parse(info)
					
					
					
					
					
				},
				mounted() {},
				methods: {
					async init() {
						
						
					},
					submitForm() {
						
						
						
						if(this.form.dateTime === undefined || this.form.textarea === undefined){
							this.$alert('输入的时间或变更原因不能为空,请重新输入!', '提示', {
							          confirmButtonText: '确定',
							         
							        });
						}else{
						var formattedDate=[];i
						for (var i = 0; i < this.form.dateTime.length; i++) {
						var dateObj = new Date(this.form.dateTime[i])
						var year = dateObj.getFullYear();
						var month = ("0" + (dateObj.getMonth() + 1)).slice(-2);
						var day = ("0" + dateObj.getDate()).slice(-2);
						var hours = ("0" + dateObj.getHours()).slice(-2);
						var minutes = ("0" + dateObj.getMinutes()).slice(-2);
						var seconds = ("0" + dateObj.getSeconds()).slice(-2);
						
						 formattedDate[i] = year + month + day + hours + minutes + seconds;
						}
						this.form.dateTime[0]=formattedDate[0]
						this.form.dateTime[1]=formattedDate[1]
						
						var createtime = new Date;
						var year = createtime.getFullYear();
						var month = ("0" + (createtime.getMonth() + 1)).slice(-2);
						var day = ("0" + createtime.getDate()).slice(-2);
						var hours = ("0" + createtime.getHours()).slice(-2);
						var minutes = ("0" + createtime.getMinutes()).slice(-2);
						var seconds = ("0" + createtime.getSeconds()).slice(-2);
						
						createtime= year + month + day + hours + minutes + seconds;
						
								console.log(this.form)
								
					const userInfo = sessionStorage.getItem("userInfo");
					
					manager = JSON.parse(userInfo)[0].username			
								
									const params = {
										manager: manager,
										cfno: this.form.cfno,
										flid: this.form.flid,
										star: this.form.star,
										ends: this.form.ends,
										startTime:this.form.dateTime[0],
										endTime: this.form.dateTime[1],
										text: this.form.textarea,
										status: '0',
										createtime: createtime,
										
										
										
									}
									console.log(params)
									editFlight(params).then(res => {
										if (res.code === 200) {
											this.$message.success('成功申请')
											this.goBack()
										} else {
											this.$message.error(res.msg || '申请失败')
										}
									}).catch(err => {
										this.$message.error('请求出错了：' + err)
									})
								
							
							}
						},
					goBack() {
						
						window.parent.menuHandle({
							id: '4',
							url: 'page/member/apply.html',
							name: '航班变更申请'
						}, false)
					}
				}
			})
		</script>
	</body>
</html>
